import * as type from './type'

const mutations = {
    [type.GOODSLIST](state, action) {
        // 追加合并返回新数组
        let arr = JSON.parse(JSON.stringify(state.goodsList))
        arr.push.apply(arr, action.payload.products.results)
        state.goodsList = arr

        state.totalPage = action.payload.products.totalPage
    },
    [type.CLEAR](state) {
        state.goodsList = []
    }
}

export default mutations